package com.devo.icecream.ui.order

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.devo.icecream.R
import com.devo.icecream.ui.theme.Grey
import com.devo.icecream.ui.theme.Main
import com.devo.icecream.ui.widget.AppButton
import com.devo.icecream.ui.widget.MakingProgressBar

/**
 * 制作中布局
 * @param name String 商品名
 * @param progress Float 制作进度
 * @param onClick Function0<Unit> 再来一杯点击事件
 */
@Composable
fun MakingLayout(name: String = "草莓酸奶杯", progress: Float = 0f, onClick: () -> Unit = {}) {

    Column(
        modifier = Modifier
            .fillMaxWidth()
            .wrapContentHeight(), horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Spacer(modifier = Modifier.height(100.dp))

        Image(painter = painterResource(id = R.mipmap.cake), contentDescription = "")

        Spacer(modifier = Modifier.height(48.dp))


        MakingProgressBar(
            modifier = Modifier
                .fillMaxWidth()
                .padding(horizontal = 56.dp)
                .height(100.dp),
            color = Main,
            progress = progress,
            backgroundColor = Grey,
            textSize = 20.sp
        )

        Spacer(modifier = Modifier.height(24.dp))

        if (progress < 1f) {
            Text(
                text = "您的${name}大约需要1分钟制作，请耐心等待",
                style = MaterialTheme.typography.h2
            )

            Spacer(modifier = Modifier.height(24.dp))

            Text(
                text = "温馨提示：制作完成后请及时取餐\n",
                color = Main,
                fontSize = MaterialTheme.typography.h3.fontSize
            )

        } else {
            Text(
                text = "您的${name}已经制作完成",
                style = MaterialTheme.typography.h1
            )

            Spacer(modifier = Modifier.height(24.dp))

            Text(text = "盖、勺餐具请推窗自取", color = Main, fontSize = MaterialTheme.typography.h3.fontSize)

            Spacer(modifier = Modifier.height(32.dp))

            AppButton(text = "再来一杯!") {
                onClick()
            }
        }


    }

}